package com.wenx.concurrent.interrupt;

/**
 * Created by wenx on 2019-10-18 13:58
 */
public class InterruptTest {
    public static void main(String[] args) throws InterruptedException {
        Thread thread1 = new Thread(() -> {
            while (true) {
                if (Thread.currentThread().isInterrupted()) {
                    System.out.println("中断，还在运行");
                    return;
                } else {
                    System.out.println("没有中断");
                }
            }
        });
        thread1.start();
        Thread.sleep(1000);
        thread1.interrupt();
        System.out.println("结束");
    }
}